using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace jQueryDotNetLib
{
	public enum AxisOptions {x, y, none};
	public enum ContainmentOptions { parent, document, window, boundingbox, none}
	public enum HelperOptions { original, clone, function }
	public enum SnapModes { inner, outter, both }

	public class DraggableOptions {
		public bool AddClasses { get;set;}
		public string AppendTo { get;set;}
		public AxisOptions Axis { get;set;}
        public string Cancel { get; set; }
        public bool ConnectToSortable { get; set; }
        public ContainmentOptions Containment { get; set; }
		public int ContainmentX1{ get;set;}
		public int ContainmentX2{ get;set;}
		public int ContainmentY1{ get;set;}
		public int ContainmentY2{ get;set;}
		public string Cursor { get;set;}
		public int CursorAtTop { get;set;}
		public int CursorAtLeft { get;set;}
		public int CursorAtRight { get;set;}
		public int CursorAtBottom { get;set;}
		public int Delay { get;set;}
		public int Distance { get;set;}
		public System.Collections.ArrayList Grid { get;set;}
		public string Handle { get;set;}
		public HelperOptions Helper { get;set;}
		public string HelperFunction { get;set;}
		public string IFrameFix { get;set;}
		public float Opacity { get;set;}
		public bool RefreshPositions { get;set;}
		public bool Revert { get;set;}
		public int RevertDuration { get;set;}
		public string Scope { get;set;}
		public bool Scroll { get;set;}
		public int ScrollSensitivity { get;set;}
		public int ScrollSpeed { get;set;}
		public bool Snap { get;set;}
		public string SnapTo { get;set;}
		public SnapModes SnapMode { get;set;}
		public int SnapTolerance { get;set;}
		public string Stack { get;set;}
		public int ZIndex { get;set;}

		public string ParentClientID { get;set;}


        public override string ToString()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            string pcid = "js_" + ParentClientID;
            sb.Append("var " + pcid + " =$('." + ParentClientID + "');");

            if (!AddClasses) sb.Append(pcid + ".draggable('option' , 'addClasses', 'false');");
            if (AppendTo != null && AppendTo != "parent") sb.Append(pcid + ".draggable('option' , 'appendTo', '" + AppendTo + "');");
            if(Axis!= AxisOptions.none) sb.Append(pcid + ".draggable('option' , 'axis', '"+Axis.ToString()+"');");
            if (Cancel != null && Cancel != "") sb.Append(pcid + ".draggable('option' , 'cancel', '" + Cancel + "');");
            if (ConnectToSortable != null && !ConnectToSortable) sb.Append(pcid + ".draggable('option' , 'connectToSortable', '" + ConnectToSortable + "');");
            if (Containment != ContainmentOptions.none) sb.Append(pcid + ".draggable('option' , 'containment', '" + Containment + "');");
            if (Cursor != null && Cursor != "auto") sb.Append(pcid + ".draggable('option' , 'cursor', '" + Cursor + "');");

            if (AddClasses != null && !AddClasses) sb.Append(pcid + ".draggable('option' , 'cursorAt', '" + CursorAtBottom + "');");


            if (AddClasses != null && !AddClasses) sb.Append(pcid + ".draggable('option' , 'delay', '" + AddClasses + "');");
            if (AddClasses != null && !AddClasses) sb.Append(pcid + ".draggable('option' , 'distance', '" + AddClasses + "');");
            if (AddClasses != null && !AddClasses) sb.Append(pcid + ".draggable('option' , 'grid', '" + AddClasses + "');");
            if (AddClasses != null && !AddClasses) sb.Append(pcid + ".draggable('option' , 'handle', '" + AddClasses + "');");
            if (AddClasses != null && !AddClasses) sb.Append(pcid + ".draggable('option' , 'helper', '" + AddClasses + "');");
            if (AddClasses != null && !AddClasses) sb.Append(pcid + ".draggable('option' , 'iframeFix', '" + AddClasses + "');");
            if (AddClasses != null && !AddClasses) sb.Append(pcid + ".draggable('option' , 'opacity', '" + AddClasses + "');");
            if (AddClasses != null && !AddClasses) sb.Append(pcid + ".draggable('option' , 'refreshPositins', '" + AddClasses + "');");
            if (AddClasses != null && !AddClasses) sb.Append(pcid + ".draggable('option' , 'revert', '" + AddClasses + "');");
            if (AddClasses != null && !AddClasses) sb.Append(pcid + ".draggable('option' , 'revertDuration', '" + AddClasses + "');");
            if (AddClasses != null && !AddClasses) sb.Append(pcid + ".draggable('option' , 'scope', '" + AddClasses + "');");
            if (AddClasses != null && !AddClasses) sb.Append(pcid + ".draggable('option' , 'scroll', '" + AddClasses + "');");
            if (AddClasses != null && !AddClasses) sb.Append(pcid + ".draggable('option' , 'scrollSensitivity', '" + AddClasses + "');");
            if (AddClasses != null && !AddClasses) sb.Append(pcid + ".draggable('option' , 'scrollSpeed', '" + AddClasses + "');");
            if (AddClasses != null && !AddClasses) sb.Append(pcid + ".draggable('option' , 'snap', '" + AddClasses + "');");
            if (AddClasses != null && !AddClasses) sb.Append(pcid + ".draggable('option' , 'snapMode', '" + AddClasses + "');");
            if (AddClasses != null && !AddClasses) sb.Append(pcid + ".draggable('option' , 'snapTolerance', '" + AddClasses + "');");
            if (AddClasses != null && !AddClasses) sb.Append(pcid + ".draggable('option' , 'stack', '" + AddClasses + "');");
            if (AddClasses != null && !AddClasses) sb.Append(pcid + ".draggable('option' , 'zIndex', '" + AddClasses + "');");
            return sb.ToString();
        }
	}


}